﻿/*$(function () {
 //全局控制ajax请求判断是否时效
 $.ajaxSetup({
 contentType : "application/x-www-form-urlencoded;charset=utf-8",
 complete : function(XMLHttpRequest, textStatus) {
 var sessionStatus = XMLHttpRequest.responseText;
 if (sessionStatus != undefined && sessionStatus != null
 && sessionStatus.indexOf("mySessionStatus:-1") > -1) {
 var yes = confirm('由于您长时间没有操作, session已过期, 请重新登录');
 if (yes) {
 top.location.href = window.location.href;
 }
 }
 }
 });

 });*/

var sAttrClass = (window.clientInformation) ? "className" : "class";
var $doc = function (id) {
    return "string" == typeof id ? document.getElementById(id) : id;
};
function Round(f) {
    return Math.round(f * 100) / 100;
}
function correctPNG() {
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5 & version < 7) && (document.body.filters)) {
        for (var j = 0; j < document.images.length; j++) {
            var img = document.images[j]
            var imgName = img.src.toUpperCase()
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
                    + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                    + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                j = j - 1
            }
        }
    }
}
var CheckInputPanel = null;
var CheckInput = function (panel) {
    if (panel)
        CheckInputPanel = panel
    else
        CheckInputPanel = $("#hongman");
    this.isPass = true;
    var focusObj = null;
    $(document).ready(function () {
        $("input[auckfun]").each(function () {
            var ts = $(this);
            ts.bind("keyup", function () {
                var fts = $(this);
                var res = eval(fts.attr('auckfun'));
                fts.attr('mfkck', res);
                markTip(fts, res);
            });
            ts.bind("mousedown", function () {
                var fts = $(this);
                markTip(fts, fts.attr('mfkck'));
            });
            ts.bind("blur", function () {
                var fts = $(this);
                $('#div_tip_' + fts.attr('id')).remove();
            });
        });
    });
    this.beginCheck = function () {
        this.isPass = true;
        focusObj = null;
    }
    this.endCheck = function () {
        if (focusObj != null) {
            focusObj.focus();
        }
        return this.isPass;
    }
    this.endAutoCheck = function (isAutoShowTip) {
        var ckIsPass = true;
        var auckList = $("input[auckfun]");
        var item;
        var itemRes = false;

        for (var i = 0; i < auckList.length; i++) {
            item = $(auckList[i]);
            itemRes = eval(item.attr('auckfun'));
            ckIsPass = ckIsPass && itemRes;
            if (isAutoShowTip && !itemRes) {
                markTip(item, false);
            }
        }
        return ckIsPass;
    }
    this.BindAutoCheckByID = function (objID, funName) {
        var ts = $('#' + objID);
        ts.attr('auckfun', funName)
        this.BindAutoCheck(ts);
    }
    this.BindAutoCheck = function (ts) {
        ts.bind("keyup", function () {
            var fts = $(this);
            var res = eval(fts.attr('auckfun'));
            fts.attr('ptitle', '');
            fts.attr('iskeeppt','');
            fts.attr('mfkck', res);
            markTip(fts, res);
        });
        ts.bind("mousedown", function () {
            var fts = $(this);
            markTip(fts, fts.attr('mfkck'));
        });
        ts.bind("blur", function () {
            var fts = $(this);
            var kp = fts.attr('iskeeppt');
            if (!(kp && kp == 'true')) {
                $('#div_tip_' + fts.attr('id')).remove();
            }
        });
    }
    function markTip(obj, res) {
        var tip = obj.attr('ptitle');
        if (!tip || tip.length == 0) {
            tip = obj.attr('title');
            if (!tip || tip.length == 0) return; //如果没有提示语则不显示提示
        }
        else {
            res = false;
        }
        var os = obj.offset();
        var objID = obj.attr('id');
        var oldTip = $('#div_tip_' + objID);
        if (oldTip) oldTip.remove();
        if ((res == undefined || res == 'undefined')) {
            CheckInputPanel.append(markInfoTip(objID, tip, os.left, os.top, obj.width()));
        }
        else if (res && (res == 'true' || res == true)) {
            CheckInputPanel.append(markOKTip(objID, tip, os.left, os.top, obj.width()));
        }
        else {
            CheckInputPanel.append(markErrTip(objID, tip, os.left, os.top, obj.width()));
        }
    }
    this.markTip = function(obj, res,error) {
        var tip = error;

        var os = obj.offset();
        var objID = obj.attr('id');
        var oldTip = $('#div_tip_' + objID);
        if (oldTip) oldTip.remove();
        if (!tip || tip.length == 0) {
            tip = obj.attr('title');
            if (!tip || tip.length == 0) return; //如果没有提示语则不显示提示
        }
        else {
            res = false;
        }
        if ((res == undefined || res == 'undefined')) {
            CheckInputPanel.append(markInfoTip(objID, tip, os.left, os.top, obj.width()));
        }
        else if (res && (res == 'true' || res == true)) {
            CheckInputPanel.append(markOKTip(objID, tip, os.left, os.top, obj.width()));
        }
        else {
            CheckInputPanel.append(markErrTip(objID, tip, os.left, os.top, obj.width()));
        }
    }
    this.markOKTip = function(obj){
        var os = obj.offset();
        var objID = obj.attr('id');
        var oldTip = $('#div_tip_' + objID);
        if (oldTip) oldTip.remove();

        //CheckInputPanel.append(markOKTip(objID, tip, os.left, os.top, obj.width()));
    }



    function markErrTip(id, title, left, top, width) {
        return $("<div id='div_tip_" + id + "' style='POSITION: absolute;WIDTH:287px;HEIGHT:20px;TOP:" + top + "px; LEFT:" + (left + width + 10) + "px'><SPAN class='onError'><SPAN class='onError_top'>" + title + "</SPAN><SPAN class='onError_bot'></SPAN></SPAN></div>");
    }
    function markInfoTip(id, title, left, top, width) {
        return $("<div id='div_tip_" + id + "' style='POSITION: absolute;WIDTH:287px;HEIGHT:20px;TOP:" + top + "px; LEFT:" + (left + width + 10) + "px'><SPAN class='onFocus'><SPAN class='onFocus_top'>" + title + "</SPAN><SPAN class='onFocus_bot'></SPAN></SPAN></div>");
    }
    function markOKTip(id, title, left, top, width) {
        return $("<div id='div_tip_" + id + "' style='POSITION: absolute;WIDTH:20px;HEIGHT:20px;TOP:" + top + "px; LEFT:" + (left + width + 5) + "px'><SPAN class='onCorrect'><SPAN class='onCorrect_top'></SPAN><SPAN class='onCorrect_bot'></SPAN></SPAN></div>");
    }
    this.setPTitle=function(objID, ptitle, iskeep) {
        var obj = $('#' + objID);
        if (obj) {
            obj.attr('iskeeppt', iskeep);
            obj.attr('ptitle', ptitle);
            if (ptitle && ptitle.length > 0) {
                markTip(obj, false);
            }
        }
    }
    this.checkObject = function (CheckValue, obj, objID, message) {
        if (CheckValue) {
            if (message && message.length > 0) {
                obj.attr("title", message);
            }
            if (focusObj == null) {
                focusObj = obj;
                obj.focus();
            }
            this.isPass = false;
            return false;
        }
        this.isPass = this.isPass && true;
        return true;
    }
    this.IsPass = function (objID, title) {
        return this.isPass;
    }
    this.setTitle = function (objID, title) {
        var obj = $("#" + objID);
        obj.attr("title", title);
    }
    this.checkSelectEqual = function (objID, equalValue, message) {
        var obj = $("#" + objID);
        return this.checkObject((obj.val() == equalValue), obj, objID, message);
    }
    this.checkTextEmpty = function (objID, message) {
        var obj = $("#" + objID);
        return this.checkObject((obj.val() == "" || obj.val().length <= 0), obj, objID, message);
    }
    this.checkTextMail = function (objID, message) {
        var obj = $("#" + objID);
        return this.checkObject(!this.IsMain(obj.val()), obj, objID, message);
    }
    this.isEqual = function (sourceID, ObjectID) {
        return this.isEqual(sourceID, ObjectID, "");
    }
    this.isEqual = function (sourceID, ObjectID, message) {
        var source = $("#" + sourceID);
        var obj = $("#" + ObjectID);
        var flag = (source.val() == obj.val());
        if (message != "") {
            this.checkObject(!flag, source, sourceID, message);
            this.checkObject(!flag, obj, ObjectID, message);
        }
        return flag;
    }
    //比较大小
    this.compareObject = function (sourceID, ObjectID) {
        return this.isEqual(sourceID, ObjectID, "");
    }
    this.compareObject = function (sourceID, ObjectID, message) {
        var source = $("#" + sourceID);
        var obj = $("#" + ObjectID);
        var arr1 = source.val().split("-");
        var arr2 = obj.val().split("-");

        var starttime = new Date(arr1[0], arr1[1], arr1[2]);
        var endtime = new Date(arr2[0], arr2[1], arr2[2]);

        var flag = (starttime > endtime);
        if (message != "") {
            this.checkObject(!flag, source, sourceID, message);
            this.checkObject(!flag, obj, ObjectID, message);
        }
        return flag;
    }
    this.checkTextNumber = function (objID, message) {
        return this.checkTextByReg(objID, message, /^\d{n}$/);
    }
    this.checkTextMoney  = function (objID, message) {
        return this.checkTextByReg(objID, message, /^[0-9]+(.[0-9]{2})?$/);
    }
    this.checkTextByReg = function (objID, reg) {
        //检查是否符合reg正则表达式
        return this.checkTextByReg(objID, '', reg);
    }
    this.checkIDCard = function (objID) {
        //检查身份证是否合法
        var msg = validateIdCard($("#" + objID).val().trim());
        var result
        if (msg == "0") { result = true; msg = "合法身份证" }
        else result = false;
        this.checkObject(!result, $("#" + objID), objID, msg);
        return result;
    }
    this.checkTextByReg = function (objID, message, reg) {
        //检查是否符合reg正则表达式
        var obj = $("#" + objID);
        return this.checkObject((!this.CheckByReg(obj.val(), reg)), obj, objID, message);
    }
    this.checkLength = function (objID, minLen, maxLen, message) {
        //检查长度是否在范围之内
        var obj = $("#" + objID);
        var l =obj.val().replace(/[ ]/g, "").length;
        return this.checkObject((l < minLen || l > maxLen), obj, objID, message);
    }
    this.checkLeastLength = function (objID, len, message) {
        //检查长度是否太短
        var obj = $("#" + objID);
        return this.checkObject((obj.val().length < len), obj, objID, message);
    }
    this.checkDesigLength = function (objID, len, message) {
        //检查是否指定长度
        var obj = $("#" + objID);
        var curLegth=obj.val().replace(/[ ]/g, "").length;
        return this.checkObject((curLegth != len), obj, objID, message);
    }
    this.TextBoxOnlyInputNumber = function (objID) {
        var obj = $("#" + objID);
        obj.keyup(function () {//先把非数字的都替换掉，除了数字和.
            obj.val(obj.val().replace(/[^\d.]/g, ""));
            //必须保证第一个为数字而不是.
            obj.val(obj.val().replace(/^\./g, ""));
            //保证只有出现一个.而没有多个.
            obj.val(obj.val().replace(/\.{2,}/g, "."));
            //保证.只出现一次，而不能出现两次以上
            obj.val(obj.val().replace(".", "$#$").replace(/\./g, "").replace("$#$", "."));
        });
    }
    this.CheckByReg = function (str, reg) {
        return reg.test(str);
    }
    this.IsTextEmpty = function (objID) {
        var obj = $("#" + objID);
        return (obj.val() == "" || obj.val().length <= 0);
    }
    this.IsMain = function (mail) {
        return this.CheckByReg(mail,/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;][,;\s]*(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*)*$/);
    }
    this.IsUserName = function (name) {
        return this.CheckByReg(name, /^(\w|[\一-\龥])*$/);
    }
    this.IsExist = function (objID) {
        return $("#" + objID).length > 0;
    }
    this.isIdCardNo = function (num){
        //if (isNaN(num)) {alert("输入的不是数字！"); return false;}
        var len = num.length, re;
        if (len == 15)
            re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{2})(\w)$/);
        else if (len == 18)
            re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\w)$/);
        else {
            //alert("输入的数字位数不对。");
            return false;
        }
        var a = num.match(re);
        if (a != null)
        {
            if (len==15)
            {
                var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
                var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
            }
            else
            {
                var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
                var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
            }
            if (!B) {
                //alert("输入的身份证号 "+ a[0] +" 里出生日期不对。");
                return false;
            }
        }
        if(!re.test(num)){
            //alert("身份证最后一位只能是数字和字母。");
            return false;
        }
        return true;
    }
}
var $apsmID = "txtLW";
function $apsm(obj) {
    var objText = $doc($apsmID);
    var objVal = objText.value;
    var str = obj.alt;
    objText.value = (str == 'back') ? objVal.substring(0, objVal.length - 1) : objVal += str;
}
var KEdit = function (contentName, upAshx) {
    var editorObj;
    KindEditor.ready(function (K) {
        editorObj = K.create('textarea[name="' + contentName + '"]', {
            resizeType: 1,
            pasteType: 1,
            allowPreviewEmoticons: false,
            uploadJson: upAshx,
            allowImageUpload: true,
            items: ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'lineheight', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', 'table', 'clearhtml', 'quickformat', '|', 'emoticons', 'image', 'multiimage', 'hr', 'anchor', 'link', 'unlink', '|', 'fullscreen']
        });
    });

    this.Editor = function () {
        return editorObj;
    }

}

function clearNoNum(obj) {
    obj.value = obj.value.replace(/[^\d.]/g, "");
    obj.value = obj.value.replace(/^\./g, "");
    obj.value = obj.value.replace(/\.{2,}/g, ".");
    obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
}
//随机码
function RndCode(len) {
    var sarr = new Array();
    var seedary;
    var i;
    var str = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9";
    sarr[0] = str.split(" ");
    seedary = ""
    for (i = 0; i < len; i++) {
        seedary += sarr[0][Math.round(Math.random() * (sarr[0].length - 1))]
    }
    return (seedary);
}
function $SetSelect(selectID, value) {
    var select = $("#" + selectID);
    if (select) {
        select.val(value);
    }
}
function enabledControl(flag, controlID) {
    var ids = controlID.split(",");
    var obj;
    if (ids.length > 0) {
        for (var i = 0; i < ids.length; i++) {
            obj = $doc(ids[i]);
            if (obj) {
                obj.disabled = !flag;
            }
        }
    }
}
//添加收藏
function addfav(title) {
    var thisURL = document.URL;
    try {
        window.external.addFavorite(thisURL, title);
    } catch (e) {
        try {
            window.sidebar.addPanel(title, thisURL, "");
        } catch (e) {
            Util.window.Alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }

}
function MD5(value, bit) {
    var sMessage = value;
    function RotateLeft(lValue, iShiftBits) {
        return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
    }
    function AddUnsigned(lX, lY) {
        var lX4,
            lY4,
            lX8,
            lY8,
            lResult;
        lX8 = (lX & 0x80000000);
        lY8 = (lY & 0x80000000);
        lX4 = (lX & 0x40000000);
        lY4 = (lY & 0x40000000);
        lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
        if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
        if (lX4 | lY4) {
            if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
            else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
        } else return (lResult ^ lX8 ^ lY8);
    }
    function F(x, y, z) {
        return (x & y) | ((~x) & z);
    }
    function G(x, y, z) {
        return (x & z) | (y & (~z));
    }
    function H(x, y, z) {
        return (x ^ y ^ z);
    }
    function I(x, y, z) {
        return (y ^ (x | (~z)));
    }
    function FF(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    }
    function GG(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    }
    function HH(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    }
    function II(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    }
    function ConvertToWordArray(sMessage) {
        var lWordCount;
        var lMessageLength = sMessage.length;
        var lNumberOfWords_temp1 = lMessageLength + 8;
        var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
        var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
        var lWordArray = Array(lNumberOfWords - 1);
        var lBytePosition = 0;
        var lByteCount = 0;
        while (lByteCount < lMessageLength) {
            lWordCount = (lByteCount - (lByteCount % 4)) / 4;
            lBytePosition = (lByteCount % 4) * 8;
            lWordArray[lWordCount] = (lWordArray[lWordCount] | (sMessage.charCodeAt(lByteCount) << lBytePosition));
            lByteCount++;
        }
        lWordCount = (lByteCount - (lByteCount % 4)) / 4;
        lBytePosition = (lByteCount % 4) * 8;
        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
        lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
        lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
        return lWordArray;
    }
    function WordToHex(lValue) {
        var WordToHexValue = "",
            WordToHexValue_temp = "",
            lByte,
            lCount;
        for (lCount = 0; lCount <= 3; lCount++) {
            lByte = (lValue >>> (lCount * 8)) & 255;
            WordToHexValue_temp = "0" + lByte.toString(16);
            WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
        }
        return WordToHexValue;
    }
    var x = Array();
    var k,
        AA,
        BB,
        CC,
        DD,
        a,
        b,
        c,
        d
    var S11 = 7,
        S12 = 12,
        S13 = 17,
        S14 = 22;
    var S21 = 5,
        S22 = 9,
        S23 = 14,
        S24 = 20;
    var S31 = 4,
        S32 = 11,
        S33 = 16,
        S34 = 23;
    var S41 = 6,
        S42 = 10,
        S43 = 15,
        S44 = 21;
    x = ConvertToWordArray(sMessage);
    a = 0x67452301;
    b = 0xEFCDAB89;
    c = 0x98BADCFE;
    d = 0x10325476;
    for (k = 0; k < x.length; k += 16) {
        AA = a;
        BB = b;
        CC = c;
        DD = d;
        a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
        d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
        c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
        b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
        a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
        d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
        c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
        b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
        a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
        d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
        c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
        b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
        a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
        d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
        c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
        b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
        a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
        d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
        c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
        b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
        a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
        d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
        c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
        b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
        a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
        d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
        c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
        b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
        a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
        d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
        c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
        b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
        a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
        d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
        c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
        b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
        a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
        d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
        c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
        b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
        a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
        d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
        c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
        b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
        a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
        d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
        c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
        b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
        a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
        d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
        c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
        b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
        a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
        d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
        c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
        b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
        a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
        d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
        c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
        b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
        a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
        d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
        c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
        b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
        a = AddUnsigned(a, AA);
        b = AddUnsigned(b, BB);
        c = AddUnsigned(c, CC);
        d = AddUnsigned(d, DD);
    }
    if (bit == 32) {
        return WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d);
    }
    else {
        return WordToHex(b) + WordToHex(c);
    }
}
//签到
function sign_Read(thisURL) {
    var oData = "";
    var SelectedIDs = "";
    oData += "SelectedIDs=" + thisURL;
    $.ajax(
        {

            url: "/BBS/sign_Read",
            type: "Post",
            data: oData,
            success: function (data) {
                if (data == "签到失败！") {
                    $("#signone").html("<a href=\"#\" onclick=\"sign_Read(" + thisURL + ")\"  class=\"Punch\">");
                    Util.window.Alert(data);
                } else if (data == -99) {
                    $("#signone").html("<a href=\"#\" onclick=\"sign_Read(" + thisURL + ")\"  class=\"Punch\">");

                } else if (data == -9) {
                    $("#signone").html("<a href=\"#\" onclick=\"sign_Read(" + thisURL + ")\"  class=\"Punch\">");
                    Util.window.Alert("您还不是红岭会员，请先成为会员！");
                } else {
                    var Message = data.indexOf("|");
                    var message = data.substr(0, Message); // 获取子字符串。
                    $("#signin").html("<div id=\"signin\" class=\"Punch_ok lf\"><div class=\"q_data rt\"><b id=\"Messages\" class=\"lf\">" + data.substr(Message + 1) + "</b></div></div></div>");
                    Util.window.Alert(message);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                Util.window.Alert("签到失败！\n信息：" + errorThrown + "," + textStatus + "\n");
            }
        }
    );

}

function ckCodeImg() {
    return !Check.IsTextEmpty('inp_ChkCode');
}
function setFocus(id) {
    $("#" + id).focus();
}
var SNSTime = function (sbtn, tip) {
    var SMSTimer;
    var SMSTimerCount = 0;
    var title = tip;
    var endTitle = $('#' + sbtn).val();
    if (endTitle == null || endTitle.length <= 0) {
        endTitle = tip
    }
    this.Begin = function () {
        SMSTimerCount = 60;
        $('#' + sbtn).attr("disabled", true);
        SMSProcess(sbtn, title,endTitle, SMSTimerCount);
    }
    this.Stop = function () {
        SMSTimerCount = -1;
        var btn = $('#' + sbtn);
        btn.attr("disabled", false);
        btn.val(endTitle);

    }
}

function SMSProcess(sbtn, tip,endTip, timerCount) {
    var btn = $('#' + sbtn);
    if (timerCount > 0) timerCount = timerCount - 1;
    if (timerCount > 0 && btn.attr("disabled")==true) {
        setTimeout("SMSProcess('" + sbtn + "','" + tip + "','" + endTip + "'," + timerCount.toString() + ");", 1000);
        btn.val(tip + "(" + timerCount.toString() + ")");
    }
    else {
        //clearTimeout(SMSTimer);
        btn.val(endTip);
        btn.attr("disabled", false);
    }
}

function validateIdCard(obj) {
    var aCity = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙 江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖 北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西 藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国 外" };
    var iSum = 0;
    //var info = "";
    var strIDno = obj;
    var idCardLength = strIDno.length;
    if (!/^\d{17}(\d|x)$/i.test(strIDno) && !/^\d{15}$/i.test(strIDno))
        return "非法身份证号"; //非法身份证号

    if (aCity[parseInt(strIDno.substr(0, 2))] == null)
        return "非法地区"; // 非法地区

    // 15位身份证转换为18位
    if (idCardLength == 15) {
        sBirthday = "19" + strIDno.substr(6, 2) + "-" + Number(strIDno.substr(8, 2)) + "-" + Number(strIDno.substr(10, 2));
        var d = new Date(sBirthday.replace(/-/g, "/"))
        var dd = d.getFullYear().toString() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
        if (sBirthday != dd)
            return "非法生日"; //非法生日
        strIDno = strIDno.substring(0, 6) + "19" + strIDno.substring(6, 15);
        strIDno = strIDno + GetVerifyBit(strIDno);
    }

    // 判断是否大于2078年，小于1900年
    var year = strIDno.substring(6, 10);
    if (year < 1900 || year > 2078)
        return "非法生日"; //非法生日

    //18位身份证处理

    //在后面的运算中x相当于数字10,所以转换成a
    strIDno = strIDno.replace(/x$/i, "a");

    sBirthday = strIDno.substr(6, 4) + "-" + Number(strIDno.substr(10, 2)) + "-" + Number(strIDno.substr(12, 2));
    var day = new Date(sBirthday.replace(/-/g, "/"))
    if (sBirthday != (day.getFullYear() + "-" + (day.getMonth() + 1) + "-" + day.getDate()))
        return "非法生日"; //非法生日
    // 身份证编码规范验证
    for (var i = 17; i >= 0; i--)
        iSum += (Math.pow(2, i) % 11) * parseInt(strIDno.charAt(17 - i), 11);
    if (iSum % 11 != 1)
        return "非法身份证号"; // 非法身份证号

//    // 判断是否屏蔽身份证
//    var words = new Array();
//    words = new Array("11111119111111111", "12121219121212121");

//    for (var k = 0; k < words.length; k++) {
//        if (strIDno.indexOf(words[k]) != -1) {
//            return 1;
//        }
//    }

    return "0";
}
//调用方法名，加载数据的目标节点,参数，回调函数
function GotoCSFunction(functionName,TargetObj, data, sucFunction) {
    $.ajax({
        type: "Post",
        url: "/MyAccount/"+functionName,
        contentType: "application/json; charset=utf-8",
        beforeSend: function () { $(TargetObj).html("<tr><td colspan=\"6\"><img src=\"/img/loading2.gif\" height=\"40\" /></td></tr>") },
        data: $.toJSON(data),
        dataType: "json",
        success: sucFunction
    });
}

Date.prototype.Format = function (formatStr) {
    var str = formatStr;
    var Week = ['日', '一', '二', '三', '四', '五', '六'];

    str = str.replace(/yyyy|YYYY/, this.getFullYear());
    str = str.replace(/yy|YY/, (this.getYear() % 100) > 9 ? (this.getYear() % 100).toString() : '0' + (this.getYear() % 100));

    str = str.replace(/MM/,parseInt(this.getMonth())+1 > 9 ? parseInt(this.getMonth())+1 : parseInt(this.getMonth())+1);
    str = str.replace(/M/g, parseInt(this.getMonth())+1);

    str = str.replace(/w|W/g, Week[this.getDay()]);

    str = str.replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate());
    str = str.replace(/d|D/g, this.getDate());

    str = str.replace(/hh|HH/, this.getHours() > 9 ? this.getHours().toString() : '0' + this.getHours());
    str = str.replace(/h|H/g, this.getHours());
    str = str.replace(/mm/, this.getMinutes() > 9 ? this.getMinutes().toString() : '0' + this.getMinutes());
    str = str.replace(/m/g, this.getMinutes());

    str = str.replace(/ss|SS/, this.getSeconds() > 9 ? this.getSeconds().toString() : '0' + this.getSeconds());
    str = str.replace(/s|S/g, this.getSeconds());

    return str;
}
function ChangeDateFormat(jsondate) {
    if (jsondate != null) {
        jsondate = jsondate.replace("/Date(", "").replace(")/", "");
        if (jsondate.indexOf("+") > 0) {
            jsondate = jsondate.substring(0, jsondate.indexOf("+"));
        }
        else if (jsondate.indexOf("-") > 0) {
            jsondate = jsondate.substring(0, jsondate.indexOf("-"));
        }

        var date = new Date(parseInt(jsondate, 10));
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();

        return date.getFullYear()
            + "年"
            + month
            + "月"
            + currentDate
            + "日"
    }
    else return "";
}

function selCheck(objID,domChunk) {
    var obj = $('#' + objID);
    $(domChunk).attr("checked", obj.attr("checked"));
}

function GetPayBackStateText(PayBackState) {
    switch (PayBackState) {
        case -6: return "担保垫付后还款";
        case -5: return "担保垫付";
        case -4: return "网站垫付后还款";
        case -3: return "网站垫付";
        case -2: return "逾期还款";
        case -1: return "迟还";
        case 0: return "待还款";
        case 1: return "提前还款";
        case 2: return "准时还款";
    }
}
function SelectMenu(i) {
    tabs_i = i;
    $('.vcon').hide().eq(tabs_i).show();
    $('.vtitle a').removeClass("cur").eq(tabs_i).addClass("cur");
}

String.prototype.trim = function () {
    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function Chinese(num)     //将阿拉伯数字的金额翻译成中文的大写数字金额表示
{
    if (!/^\d*(\.\d*)?$/.test(num))
        return "格式有误";
    var AA = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
    var BB = new Array("", "拾", "佰", "仟", "万", "亿", "圆", "");
    var CC = new Array("角", "分", "厘");
    var a = (num).replace(/(^0*)/g, "").split("."), k = 0, re = "";

    for (var i = a[0].length - 1; i >= 0; i--) {
        switch (k) {
            case 0: re = BB[7] + re; break;
            case 4: if (!new RegExp("0{4}\\d{ " + (a[0].length - i - 1) + "}$ ").test(a[0]))
                re = BB[4] + re; break;
            case 8: re = BB[5] + re; BB[7] = BB[5]; k = 0; break;
        }

        if (a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re; k++;
    }

    if (a.length > 1)   //加上小数部分(如果有小数部分)
    {
        re += BB[6];
        for (var i = 0; i < a[1].length; i++) {
            re += AA[a[1].charAt(i)] + CC[i];
            if (i == 2) break;
        }
    }
    return re.length == 0 ? "" : (a.length > 1 ? re : re + "元整");
}

function checkKaptchaCode(randomPageId) {
    if(!Check.checkLength('kaptchaCode', 4, 4)){
        Util.window.Alert("您输入的验证码不正确，请查证后重试");
        return false;
    }
    return true;
}

/**
 * 是否登录
 * @returns {Boolean}
 */
function isLogin(){
    var result;
    $.ajax({
        url : '/security/isLogon',
        data : null,
        type : 'post',
        cache : false,
        dataType : 'json',
        success : function(data) {
            if (data.success == true) {
                result=true;
            } else {
                var yes = confirm('由于您长时间没有操作, session已过期, 请重新登录');
                if (yes) {
                    top.location.href =window.location.href;
                }
                result=false;
            }
        },
        error : function() {
            Util.window.Alert("请求异常，稍后再试！");
            result=false;
        }
    });
    return result;
}
